<?php

namespace Trawind\Rocketmq\Helpers;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\PendingDispatch;
use Trawind\Basics\Traits\HasFactory;
use Trawind\Helpers\UserHelper;

/**
 * Class RocketMQHelper
 * @package Trawind\Rocketmq\Helpers
 */
class RocketMQHelper
{
    
    use HasFactory;

    /**
     * @var ShouldQueue $job
     */
    protected $job;


    /**
     * RocketMQHelper constructor.
     * @param  ShouldQueue  $job
     */
    protected function __construct($job)
    {
        $this->job = $job;
    }


    /**
     * Dispatch the job with the given arguments.
     * @return PendingDispatch
     */
    public function dispatch(): PendingDispatch
    {
        return $this->job::dispatch(...func_get_args())
            ->onConnection('rocketmq')
            ->delay(now()->addSeconds(2));
    }
}